import { State } from "./AState";
import { HierarchicalStateMachine } from "./HierarchicalStateMachine";
import {  HSMBase, UpdateResult } from "./HSMBase";

export class SubMachineState<T extends IStateArg = IStateArg> extends HierarchicalStateMachine<T>
{

    // get actions
    // 
    public getActions(arg:T):Action[]
    {
        return super.getActions(arg);
    }

    public Update(arg:T): UpdateResult
    {
        return super.Update(arg);
    }

    public getStates():State[]
    {
        if(this.CurrentState)
        {
            return [this,... this.CurrentState.getStates()];
        }
        else
        {
            return [this]
        }
    }

    public getLevel():number
    {
        if(!this.Parent)
        {
            throw new Error("此层次状态机未添加到父节点");
        }
        return this.Parent.getLevel()+1;
    }
}
